;
(function() {
  new Vue({
    el: '#feedbackDetail',
    data: {
      flag: true,
      columns: '#',
      pagetotal: 0,
      page: 1,
      limit: 10,
      data: [],
      pageCounts: [10, 15, 20],
      quanxian: JSON.parse(window.localStorage.getItem('permissions')),
      articleId: hlUrlUtil.GetQueryString('articleId'),
      isShow: [],
    },
    filters: {
      framtTime(time) {
        return hlDateUtil.formatDate(time, 'yyyy-MM-dd HH:mm:ss')
      },
      formatDate: function(time) {
        if (time === undefined) return '--'
        return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd')
      },
    },
    methods: {
      // 设置背景色
      addbgcolor(index) {
        let el = document.querySelectorAll('.house-two-tone');
        let el0 = document.querySelectorAll('.house-operate')
        el[index].classList.add('house-two-tone-hover')
        el0[index].classList.add('house-two-tone-hover')
      },
      //删除背景色
      removebgcolor(index) {
        let el = document.querySelectorAll('.house-two-tone');
        let el0 = document.querySelectorAll('.house-operate')
        el[index].classList.remove('house-two-tone-hover')
        el0[index].classList.remove('house-two-tone-hover')
      },
      eventType(type) {
        this.typeStatus = type;
      },
      //展示数量
      eventPage(num) {
        this.limit = num;
        this.getListData()
      },
      //获取反馈列表
      getListData() {
        var that = this
        hlhttp.get({
          url: 'portal/feedbacks',
          data: {
            "article_id": this.articleId,
            "page": this.page,
            "limit": this.limit
          },
          success: (data) => {
            data.activityAttendList.forEach(item => {
              if ('submitContent' in item) {
                item.submitContent = JSON.parse(item.submitContent)
              }
            })
            that.data = data;
            $("#page").initPage(data.totalPage, this.page, (n) => {
              if (this.page == n) {
                return
              }
              this.page = n;
              this.getListData();
            });
          }
        })
      },


      seeAll(val) {
        if (this.isShow.indexOf(val) == -1) {
          this.isShow.push(val)
        } else {
          this.isShow.splice(this.isShow.indexOf(val), 1)
        }
      },

      feedbackdel(id) {
        var that = this
        hlhttp.delete({
          url: 'portal/del_feedback?activity_attend_id=' + id,
          data: {
            "activity_attend_id": id,
          },
          success: (data) => {
            hl.toast('删除成功')
            that.getListData()
          }
        })
      }
    },
    created() {
      hlSelectUi()
    },
    mounted() {
      this.getListData()
    }
  })
}())
